<?php

namespace Dreamcat\ConfigClient\Api;

use Dreamcat\ConfigClient\Factory\NacosServerFactory;
use Dreamcat\ConfigClient\Factory\ReadProcessFactory;
use Dreamcat\ConfigClient\Impl\NacosConfigListener;
use Dreamcat\ConfigClient\Impl\Saver\SingleSaver;
use Dreamcat\ConfigClient\Popo\NacosAppInfo;
use PHPUnit\Framework\TestCase;

/**
 * -
 * @author vijay
 */
class ReadProcessTest extends TestCase
{
    public function testReadConfig()
    {
        $process = ReadProcessFactory::createProcess();
        /** @var NacosAppInfo[] $list */
        $list = [new NacosAppInfo(), new NacosAppInfo()];
        $list[0]->setDataId("test");
        $list[1]->setDataId("test")->setNamespaceName("409194c0-c4f4-413f-b2af-bcff8662a83d");
        $process->setConfigServerLintener(new NacosConfigListener(NacosServerFactory::buildServer(), $list));
        $process->setConfigSaver(new SingleSaver(__DIR__ . "/../../../cache/config.php"));
        $process->readConfig();
    }
}

# end of file
